import re
import requests

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
}
#
# url = 'https://www.yayameiju.com/play/53231-0-0.html'
# resp = requests.get(url, headers=headers,verify=False)
# resp.encoding = 'utf-8'
# data = resp.text
# # print(data)
# with open('电影.html', 'w', encoding='utf-8') as f:
#     f.write(data)
# # 在源码中可以用正则找到https://vod6.bdzybf7.com/20231118/cUYHi2tB/index.m3u8
#
# with open('电影.html', encoding='utf-8') as f:
#     data = f.read()
# # 在源码中可以用正则找到https://vod6.bdzybf7.com/20231118/cUYHi2tB/index.m3u8
#
# rege = r'now="(.*?index\.m3u8)"'
# match = re.search(rege, data)
#
# if match:
#     first_m3u8_url = match.group(1)
#     print(first_m3u8_url)
# else:
#     print('No match found.')
#
#
# resp = requests.get(first_m3u8_url, headers=headers,verify=False)
# with open('first_m3u8_url','wb')as f:
#         f.write(resp.content)
#
# resp.encoding='utf-8'
# print(resp.text)
"""获取得到第一个m3u8响应的内容
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1500000,RESOLUTION=1280x720
/20231118/cUYHi2tB/1500kb/hls/index.m3u8
"""
with open('first_m3u8_url','r',encoding='utf-8')as f:
        data=f.read()

# print(data.split('/',3)[-1])
"""
1500kb/hls/index.m3u8
"""
suffix=data.split('/',3)[-1]

